<#assign security=JspTaglibs["/WEB-INF/security.tld"] />
<!DOCTYPE html>
<html>
<head>
    <title>操作手册</title>
    <script type="text/javascript">
        $(function () {
            $("#importBtn").click(function () {
                $("#uploadForm input[type=file]").click();
            });

            $("#uploadForm input[name=file]").live("change", function () {
                $("#uploadForm").ajaxSubmit({
                    success: function (data) {
                        $("#uploadForm input[name=file]").val("");
                        var result = JSON.parse(data);
                        if (result.returnCode == 1) {
                            $.showMessage({parentId: "showMessage", message: "数据上传成功！", type: "success"});
                            refreshTable(1);
                        } else {
                            $.showMessage({parentId: "showMessage", message: "<strong>错误信息</strong>：" + result.returnMsg, type: "error"});
                        }
                    }
                });
            });
        });
        function downloadDoc(docUrl) {
            $("#fileName").val(docUrl);
            $("#clientFileName").val(docUrl);
            $("#Form_Download").submit();
        }

        function refreshTable(currentPage) {
            if (currentPage) {
                $("input[name=currentPage]").val(currentPage);
            }
            $("#search_document_table").ajaxSubmit({
                url: '${absoluteContextPath}/system/document/ajaxList',
                success: function (data) {
                    var data = JSON.parse(data);
                    if (data.returnCode == 1) {
                        $("#tableContent").html(data.content.data);
                    } else {
                        $.showMessage({parentId: "showMessage", message: "表格数据加载异常！", type: "success"});
                    }
                }
            });
        }
    </script>
</head>
<body>

<div class="breadcrumbs">
    <ol class="breadcrumb">
        <li><a href="${absoluteContextPath}/home"><i class="fa fa-home"></i>首页</a></li>
        <li><a href="#">系统管理</a></li>
        <li class="active">操作手册</li>
    </ol>
</div>

<div class="main">
    <!-- row -->
    <div class="row">
        <div class="col-md-12">
            <section class="tile" style="display: none">
                <!-- tile body -->
                <div class="tile-body">
                    <div class="form-horizontal">
                        <form id="search_document_table" action="${absoluteContextPath}/system/document/list"
                              method="post">
                            <input type="hidden" name="pageSize" value="${documentsTable.page.pageSize}"/>
                            <input type="hidden" name="currentPage" value="${documentsTable.page.currentPage}"/>
                        </form>
                    </div>
                </div>
            </section>
            <section class="tile">
                <div id="showMessage"><#include "../../message.ftl" /></div>
                <div class="tile-header">
                    <h1>
                    <@security.authorize ifAnyGranted="ROLE_DOCUMENT_I">
                        <button id="importBtn" type="button" class="btn btn-cyan"><i
                                class="fa fa-arrow-circle-o-down"></i><span class="margin-left-5">文档上传</span></button>
                    </@security.authorize>
                    </h1>
                </div>
                <div class="tile-body nopadding">
                    <div class="table-responsive" id="tableContent">
                    <#include "table.ftl"/>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>
    <form id="uploadForm" method="post" enctype="multipart/form-data"
          action="${absoluteContextPath}/system/document/importIndex">
        <input type="file" name="files" value="" / >

    </form>
    <form id="Form_Download" action="${absoluteContextPath}/system/document/downloadDoc"
          method="post"
          style="display: none">
        <input id="fileName" name="fileName" type="hidden" value=""/>
        <!-- 下载潜在客户导入模板 -->
        <input id="clientFileName" name="clientFileName" type="hidden" value="操作手册.docx"/>
        <!-- 下载潜在客户导入模板 -->
    </form>
</div>
</body>
</html>
